package com.BMS.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.springframework.format.annotation.DateTimeFormat;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;

/**
 * 图书信息实体类
 * @author lenovo
 *
 */
@Entity
@Table(name = "book")
public class Book {
	
	private String book_ID;  // 图书ID
	
	private String title;  // 图书名称
	
	private String type;  // 图书种类
	
	private String author;  // 图书作者
	
	private String publisher;  // 出版社
	
	@JSONField(format="yyyy-MM-dd")
	@DateTimeFormat(pattern="yyyy-MM-dd")
	private Date publish_date;  // 出版日期
	
	private double price;  // 价格
	
	public Book() {
		
	}


	@Id
	@Column(name = "book_ID", nullable = false, unique = true, length = 12)
	public String getBook_ID() {
		return book_ID;
	}

	public void setBook_ID(String book_ID) {
		this.book_ID = book_ID;
	}

	@Column(name = "title", nullable = false, length = 15)
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@Column(name = "type", nullable = false, length = 10)
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	@Column(name = "author", nullable = false, length = 12)
	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	@Column(name = "publisher", nullable = false, length = 10)
	public String getPublisher() {
		return publisher;
	}

	public void setPublisher(String publisher) {
		this.publisher = publisher;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "publish_date", nullable = false)
	public Date getPublish_date() {
		return publish_date;
	}

	public void setPublish_date(Date publish_date) {
		this.publish_date = publish_date;
	}

	@Column(name = "price", nullable = false, length = 6)
	public double getPrice() {
		return price;
	}

	public void setPrice(double price) {
		this.price = price;
	}
	
	@Override
	public String toString() {
		JSONObject obj = new JSONObject();
		return obj.toJSONString(this);
	}
}
